Repository navigation
Improve stubs for flatten and flatten_fieldsets - #2572
Merged
Merged
Conversation
ngnpope
force-pushed
the
improve-flatten-functions
branch
from
March 18, 2025 16:57
350a803 to
046aa7c
Compare
ngnpope
marked this pull request as ready for review
March 18, 2025 17:11
This comment was marked as outdated.
This comment was marked as outdated.
ngnpope
force-pushed
the
improve-flatten-functions
branch
4 times, most recently
from
March 25, 2025 16:41
4c89ad4 to
2438ddb
Compare
sobolevn
reviewed
Mar 25, 2025
sobolevn
left a comment
Member
There was a problem hiding this comment.
Looks like pyright is not happy with something :(
ngnpope
force-pushed
the
improve-flatten-functions
branch
2 times, most recently
from
March 25, 2025 16:59
d927064 to
bca1c4d
Compare
Member
Author
Yeah... Looking into that. It's hard to get the different type checkers to agree on pretty much anything at all it seems 😞 I've fixed a bunch of the pyright issues, ignored a few around the model fields that can't be handled until we support making fields generic as per #2214, and a handful still to check. The good news is that, by adding some testing, I ended up simplifying the implementation. |
This renames `_DisplayT` to `_ListDisplayT` and creates a new `_DisplayT` alias with the contents of the `_ListOrTuple`. This will be used in the next commit.
These functions are implemented in a generic way that doesn't generally care about the content. The existing return type of `Callable | str` makes these awkward to use. I've changed the use of `Sequence` in the `_FieldGroups` alias to use `_ListOrTuple`. This is another case where `ModelAdmin.fields` and the `"fields"` item in fieldsets are presumed by Django to be a `list` or `tuple`, e.g. there are some system checks that ensure this. See https://github.com/django/django/blob/afbb8c709d40e77b3f71c152d363c5ad95ceec2d/django/contrib/admin/utils.py#L102-L120
ngnpope
force-pushed
the
improve-flatten-functions
branch
from
March 25, 2025 17:21
bca1c4d to
d1a968e
Compare
Member
Author
|
Success @sobolevn! Somehow it's turned out rather clean after my silly false starts! 😅 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have made things!
These functions are implemented in a generic way that doesn't generally care about the content. The existing return type of
Callable | strmakes these awkward to use.I've changed the use of
Sequencein the_FieldGroupsalias to use_ListOrTuple. This is another case whereModelAdmin.fieldsand the"fields"item in fieldsets are presumed by Django to be alistortuple, e.g. there are some system checks that ensure this.See https://github.com/django/django/blob/afbb8c709d40e77b3f71c152d363c5ad95ceec2d/django/contrib/admin/utils.py#L102-L120
Related issues
N/A